<!doctype html>
<html lang="en">

<head>

    <title>鼠标的移动事件</title>
    <style>
        div {
            width: 300px;
            height: 300px;
            border: 1px solid red;
        }
    </style>
</head>
<script >

    //示例：当鼠标在div上移动的时候显示鼠标的坐标
    function fun(e) {
        var x = e.clientX;
        var y = e.clientY;

        //显示在文本框中
        var txt = document.getElementById("txt");
        txt.value = x + " :" + y;
    }

</script>

<body>
    <input type="text" name="" id="txt">
    <div onmousemove="fun(event)"></div>
    <!--通过event对象的属性clientX和clientY，可以得到其鼠标的x,y坐标-->
</body>

</html>